package com.zzyq.pc.web.report.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.zzyq.pc.web.configure.service.ICompanyService;
import com.zzyq.pc.web.report.service.IReportService;
import com.zzyq.pc.web.report.service.IReportTask;

@Service
public class ReportTask implements IReportTask {

	@Autowired
	private ICompanyService companyService;
	@Autowired
	private IReportService reportService;

	// 每日凌晨8点触发
	@Scheduled(cron = "0 0 8 * * ? ")
	// @Scheduled(cron = "0 0 12 * * ? ")
	// @Scheduled(cron = "0 */1 * * * ?")
	@Override
	public void scheduleDayRpt() {
		List<Integer> idList = companyService.selectAllCompanyId();
		if (null != idList && !idList.isEmpty() && idList.size() > 0) {
			// 每个团体ID生成一个报告
			for (Integer companyId : idList) {
				try {
					reportService.creatReport(companyId);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

}
